package com.zjh.common.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ScheduleAspect {

    @Value("${schedule.flag:true}")
    private boolean scheduleFlag;

    @Around("@annotation(org.springframework.scheduling.annotation.Scheduled)")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        if (scheduleFlag) {
            joinPoint.proceed(); // 如果flag为true，则执行定时任务
        }
    }
}